﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CommonFramework.Utility;
using Back.Xinkui.Entity.Advert;
using Back.Xinkui.DataAccess.Advert;
using Back.Xinkui.Common;

public partial class advert_advertList : System.Web.UI.Page
{
    protected int SpaceID
    {
        get { return WebHelper.GetQueryStringValue<int>("ID", 0); }
    }

    protected int BoardID = 1;

    protected List<AdvertEntity> AdvertList { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        AdvertSpaceEntity entity = AdvertDataAccess.GetAdvertSpaceByID(SpaceID);
        if (!IsPostBack)
        {
            AspNetPager1.PageSize = ddlPageCount.SelectedValue.ToType<int>(10);
            BindAdvertList();
        }

    }
    protected void BindAdvertList()
    {
        AdvertEntity sEntity = new AdvertEntity();
        sEntity.SpaceID = SpaceID;
        sEntity.AdvertName = txtAdvrtName.Text.Trim();
        sEntity.SpaceName = txtSpaceName.Text.Trim();
        sEntity.KeyWords = txtKey.Text.Trim();
        sEntity.AdvertType = Convert.ToInt32(this.ddpAdvertType.SelectedValue);
        sEntity.Status = Convert.ToInt32(this.ddpStatus.SelectedValue);
        sEntity.BeginDate = txtStartTime.Text.Trim();
        sEntity.EndDate = txtEndTime.Text.Trim();
        Pager page = new Pager { PageIndex = AspNetPager1.CurrentPageIndex, PageSize = AspNetPager1.PageSize };

        AdvertList = AdvertDataAccess.GetAdvertList(sEntity, page);

        AspNetPager1.RecordCount = page.TotalCount;
    }

    protected void btnSerach_Click(object sender, EventArgs e)
    {
        BindAdvertList();
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindAdvertList();
    }
    protected void ddlPageCount_SelectedIndexChanged(object sender, EventArgs e)
    {
        AspNetPager1.PageSize = Convert.ToInt32(ddlPageCount.SelectedValue);
        BindAdvertList();
    }
}